#include "mydialoglocate.h"

MyDialogLocate::MyDialogLocate(QWidget *parent)
	: QDialog(parent)
	, ui(new Ui::MyDialogLocateClass())
{
	ui->setupUi(this);


}

MyDialogLocate::~MyDialogLocate()
{
	delete ui;
}

void MyDialogLocate::set_spin_range(int row_count, int column_count)
{
	ui->spinBox_Row->setMaximum(row_count - 1);
	ui->spinBox_Column->setMaximum(column_count - 1);
}

#include <QCloseEvent>
void MyDialogLocate::closeEvent(QCloseEvent* event)
{
	event->accept();
	emit change_action_enable(true);
}

void MyDialogLocate::showEvent(QShowEvent* event)
{
	event->accept();
	emit change_action_enable(false);
}

void MyDialogLocate::set_spin_value(int row_number, int column_number)
{
	ui->spinBox_Row->setValue(row_number);
	ui->spinBox_Column->setValue(column_number);
}

void MyDialogLocate::on_pushButton_SetText_clicked()
{
	QString text = ui->lineEdit->text();
	int row = ui->spinBox_Row->value();
	int column = ui->spinBox_Column->value();

	//设置完一个后，自动切换到下一个
	if (ui->checkBox_Row->isChecked())
		ui->spinBox_Row->setValue(row + 1);
	if (ui->checkBox_Column->isChecked())
		ui->spinBox_Column->setValue(column + 1);

	emit cell_text_changed(row, column, text);
}
